﻿@{
    ViewData["Title"] = "照片档案检索";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section head{
    <link href="/css/bootstrap.min.css?v=3.3.6" rel="stylesheet" />
    <link href="/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" />
    <link href="/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet" />
    <link href="/css/animate.min.css" rel="stylesheet" />
    <link href="/css/style.min.css?v=4.1.0" rel="stylesheet" />
    <style type="text/css">
        .dSearch .btn {
            margin-top: 10px;
        }

        .dataTables_wrapper {
            padding-bottom: 0px;
        }

        div.dataTables_scrollBody table {
            margin-top: -18px !important;
        }

        .fixed-table-pagination .pagination-detail, .fixed-table-pagination div.pagination {
            margin-bottom: 0px;
        }

        #dSearch table tr td {
            padding: 8px;
        }

        #dSearch .input-group {
            width: 100%;
            margin-bottom: 16px;
        }

        #dSearch .input-group-addon {
            width: 100px;
        }

        #dSearch .fix-border {
            border-left: none;
            border-right: none;
        }

        .dSearch .form-control {
            display: inline-block;
        }

        .dSearcha a.btn {
            margin-top: 0;
        }
    </style>
}
<form id="form1" runat="server">
    <div id="dMain">
        <div class="wrapper wrapper-content animated fadeInRight">
            <div class="ibox" style="margin-bottom: 0px;">
                <div class="ibox-title">
                    <h5>照片档案</h5>
                    <div class="ibox-tools">
                        <a class="btn btn-primary btn-circle btn-outline" title="刷新" href="javascript:location.href=location.href;" style="margin-top: -7px;"><i class=" fa fa-refresh"></i></a>
                    </div>
                </div>
                <div class="ibox-content">
                    <div class="dSearch dSearcha">
                        <asp:TextBox ID="txtFileNo" runat="server" CssClass="form-control" placeholder="档号" Width="120"></asp:TextBox>
                        <asp:DropDownList ID="ddlFTerm" runat="server" CssClass="form-control" Width="100"></asp:DropDownList>
                        <asp:TextBox ID="txtAY" runat="server" CssClass="form-control" placeholder="题名" Width="200"></asp:TextBox>
                        <asp:LinkButton ID="lbtnSearch" runat="server" CssClass="btn btn-sm btn-primary" OnClick="lbtnSearch_Click"><i class="icon-search"></i>&nbsp;快速检索</asp:LinkButton>
                        <a id="ShowSearch" class="btn btn-sm btn-primary" onclick="ShowDivOfPage('#myModal','综合检索',500,510)"><i class="icon-search"></i>&nbsp;综合检索</a>
                        <asp:LinkButton ID="lbtnAll" runat="server" CssClass="btn btn-sm btn-primary" OnClick="lbtnAll_Click"><i class="icon-table"></i>&nbsp;查看全部</asp:LinkButton>
                    </div>
                    <div id="toolbar" class="dSearch">

                    </div>
                    <table id="tabData" class="table table-bordered" style="width: 1600px;">
                        <thead>
                            <tr>
                                <th>#</th>
                                <th>案卷档号</th>
                                <th>题名</th>
                                <th>文件开始时间</th>
                                <th>文件结束时间</th>
                                <th>件数</th>
                                <th>照片数</th>
                                <th>保管期限</th>
                                <th>归档日期</th>
                                <th>备注</th>
                            </tr>
                        </thead>
                    </table>
                    <hr style="height: 1px; border: none; border-top: 1px dashed #1E90FF; margin-top: 3px; margin-bottom: 5px;" />
                    <table id="tabData2" class="table table-bordered" style="min-width: 200px; width: 100%;">
                        <thead>
                            <tr>
                                <th>#</th>
                                <th>序号</th>
                                <%--
                                <th>档号</th>--%>
                                <th>期限</th>
                                <th>责任者</th>
                                <%--
                                <th>照片组号</th>--%>
                                <th>照片号</th>
                                <th>摄影者</th>
                                <%--
                                <th>主要人物</th>
                                <th>拍摄地点</th>--%>
                                <th>组题名</th>
                                <th>摄影时间</th>
                                <th>开放状态</th>
                                <th>备注</th>
                            </tr>
                        </thead>
                        <tbody>
                        </tbody>
                    </table>
                    <div id="dNum" style="background-color: #F5F5F5">照片档案图片量共：<%=GetNum() %>张</div>
                </div>
            </div>
        </div>
    </div>

    <div id="myModal" style="display: none;">
        <div id="dSearch" class="modal-body" style="height: 415px;">
            <div class="input-group">
                <span class="input-group-addon">题名</span>
                <asp:TextBox ID="txtTitle" runat="server" CssClass="form-control"></asp:TextBox>
            </div>
            <div class="input-group">
                <span class="input-group-addon">归档年度</span>
                <asp:TextBox ID="txtReturnYear1" runat="server" CssClass="form-control" onclick="WdatePicker({dateFmt:'yyyy'})"></asp:TextBox>
                <span class="input-group-addon fix-border fix-padding" style="width: 30px;">至</span>
                <asp:TextBox ID="txtReturnYear2" runat="server" CssClass="form-control" onclick="WdatePicker({dateFmt:'yyyy'})"></asp:TextBox>
            </div>
            <div class="input-group">
                <span class="input-group-addon">文件开始时间</span>
                <asp:TextBox ID="txtStartDate1" runat="server" CssClass="form-control" onclick="WdatePicker({dateFmt:'yyyyMMdd',errDealMode:3})" DataType="zzs" Msg="文件开始时间格式不正确!"></asp:TextBox>
                <span class="input-group-addon fix-border fix-padding" style="width: 30px;">至</span>
                <asp:TextBox ID="txtStartDate2" runat="server" CssClass="form-control" onclick="WdatePicker({dateFmt:'yyyyMMdd',errDealMode:3})" DataType="zzs" Msg="文件开始时间格式不正确!"></asp:TextBox>
            </div>
            <div class="input-group">
                <span class="input-group-addon">文件结束时间</span>
                <asp:TextBox ID="txtEndDate1" runat="server" CssClass="form-control" onclick="WdatePicker({dateFmt:'yyyyMMdd',errDealMode:3})" DataType="zzs" Msg="文件结束时间格式不正确!"></asp:TextBox>
                <span class="input-group-addon fix-border fix-padding" style="width: 30px;">至</span>
                <asp:TextBox ID="txtEndDate2" runat="server" CssClass="form-control" onclick="WdatePicker({dateFmt:'yyyyMMdd',errDealMode:3})" DataType="zzs" Msg="文件结束时间格式不正确!"></asp:TextBox>
            </div>
            <div class="input-group">
                <span class="input-group-addon">保管期限</span>
                <asp:DropDownList ID="ddlTerm" runat="server" CssClass="form-control"></asp:DropDownList>
            </div>
            <div class="input-group">
                <span class="input-group-addon">全宗号</span>
                <asp:TextBox ID="txtQZH" runat="server" CssClass="form-control"></asp:TextBox>
            </div>
            <div class="input-group">
                <span class="input-group-addon">实体分类号</span>
                <asp:TextBox ID="txtSTFLH" runat="server" CssClass="form-control"></asp:TextBox>
            </div>
            <div class="input-group">
                <span class="input-group-addon">目录号</span>
                <asp:TextBox ID="txtMLH1" runat="server" CssClass="form-control" DataType="zzs" Msg="目录号格式不正确!"></asp:TextBox>
                <span class="input-group-addon fix-border fix-padding" style="width: 30px;">至</span>
                <asp:TextBox ID="txtMLH2" runat="server" CssClass="form-control" DataType="zzs" Msg="目录号格式不正确!"></asp:TextBox>
            </div>
            <div class="input-group">
                <span class="input-group-addon">案卷号</span>
                <asp:TextBox ID="txtAJH1" runat="server" CssClass="form-control" DataType="zzs" Msg="案卷号格式不正确!"></asp:TextBox>
                <span class="input-group-addon fix-border fix-padding" style="width: 30px;">至</span>
                <asp:TextBox ID="txtAJH2" runat="server" CssClass="form-control" DataType="zzs" Msg="案卷号格式不正确!"></asp:TextBox>
            </div>
            <div class="input-group">
                <span class="input-group-addon">案卷档号</span>
                <asp:TextBox ID="txtDH" runat="server" CssClass="form-control"></asp:TextBox>
            </div>
            <div class="input-group">
                <span class="input-group-addon">密级</span>
                <asp:DropDownList ID="ddlSecretLevel" runat="server" CssClass="form-control"></asp:DropDownList>
            </div>
            <div class="input-group" style="margin-bottom: 0px;">
                <span class="input-group-addon">备注</span>
                <asp:TextBox ID="txtRemark" runat="server" CssClass="form-control"></asp:TextBox>
            </div>
        </div>
        <div class="modal-footer">
            <asp:Button ID="btnSearch" runat="server" CssClass="btn btn-primary btn-sm" OnClientClick="return verfic('tip', '#dSearch');" OnClick="btnSearch_Click" Text="检索" />
            <input id="btnClose" type="button" class="btn btn-default btn-sm" value="取消" onclick="CloseDiv()" />
        </div>
    </div>
</form>
@section scripts{
    <script src="/js/jquery.min.js?v=2.1.4"></script>
    <script src="/js/bootstrap.min.js?v=3.3.6"></script>
    <script src="/js/plugins/jeditable/jquery.jeditable.js"></script>
    <script src="/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
    <script src="/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
    <script src="/js/plugins/bootstrap-table/bootstrap-table-export.js"></script>
    <script src="/js/plugins/bootstrap-table/tableExport.js"></script>
    <script src="/js/plugins/bootstrap-table/bootstrap-table-cookie.js"></script>
    <script src="/js/store.js"></script>
    <script src="/js/My97DatePicker/WdatePicker.js"></script>
    <script src="/js/plugins/layer/layer.min.js"></script>
    <script src="/js/verification.js"></script>
    <script src="/js/zuiCode.js"></script>

    <script type="text/javascript">
        var tabHeight = 0;
        $(function () {
            tabHeight = (GetHeight() - 160) / 2//将两个表格平分高
            BindTab2("");
            $('#tabData').bootstrapTable({
                height: tabHeight + 50,
                data: $("#dJson").text() != "" ? JSON.parse($("#dJson").text()) : "",
                dataType: "json",
                columns: [
                    { align: 'center', width: "50px", checkbox: true },
                    { field: 'DH', align: 'center', width: "100px", sortable: true },
                    { field: 'Title', align: 'left', width: "0" },
                    { field: 'StartDate', align: 'center', width: "100px", sortable: true },
                    { field: 'EndDate', align: 'center', width: "100px", sortable: true },
                    { field: 'ItemCount', align: 'center', width: "100px", sortable: true },
                    { field: 'ImgCount', align: 'center', width: "100px", sortable: true },
                    { field: 'Term', align: 'center', width: "100px", sortable: true },
                    { field: 'ReturnDate', align: 'center', width: "100px", sortable: true },
                    { field: 'Remark', align: 'left', width: "200px" },
                ],
                toolbar: '#toolbar',//工具按钮用哪个容器
                buttonsClass: "sm btn-white",//按钮class
                pageSize: 100,//分页条数
                clickToSelect: true,//设置true将在点击行时，自动选择单选或复选框
                singleSelect: false,//为true则禁止多选
                cache: false,//是否缓存
                cookie: true,//是否启用cookie
                cookieIdTable: "Image",//cookie键值
                pagination: true,//是否分页
                showColumns: true,//是否显示所有的列
                showRefresh: true,//是否显示刷新按钮
                search: true,//是否启用搜索
                showPaginationSwitch: true,//是否显示分页切换按钮
                showExport: true,//是否启用导出
                onClickRow: function (row, obj) { //单击行事件
                    $(obj).parent().find("tr").removeClass("selected");
                    $(obj).addClass("selected");

                    //根据选中的行获取子表数据
                    GetSonData(row.ID);
                },
                onSearch: function (text) {
                    if (text != "") {
                        $("#tabData tbody tr").each(function (z) {
                            $("td:not(.bs-checkbox)", this).each(function (i) {
                                if (i != 0) {
                                    var str = "<span class=\"bg-yellow\">" + text + "</span>";
                                    var NewText = $("#tabData tbody tr").eq(z).find("td").eq(i).text().replaceAll(text, str);
                                    $("#tabData tbody tr").eq(z).find("td").eq(i).html(NewText);
                                }
                            })
                        })
                    }
                }
            });
        })



        //设置快捷键
        document.onkeydown = function () {
            //焦点不在控件上的时候执行
            if (document.activeElement.className.indexOf("form-control") == -1) {
                var keycode = window.event.keyCode;
                if (keycode == '<%=HotKey26 %>') {
                    $("#btnClose").click();
                    return false;
                }
                if (keycode == '<%=HotKey2 %>') {
                    $("#btnSearch").click();
                    return false;
                }
            }
        }

        //获取子表数据
        function GetSonData(_ParentID) {
            // DataLoading();
            $.ajax({
                type: "post",
                url: "/ashx/Files.ashx",
                dataType: "json",
                async: true,
                data: { type: "GetImagePhoto", ParentID: _ParentID },
                success: function (msg) {
                    if (msg.result == 1) {
                        BindTab2(msg.JsonData);
                        $("#htmlTip").remove();
                    }
                }
            });
        }

        function BindTab2(JsonData) {
            $('#tabData2').bootstrapTable('destroy');
            $('#tabData2').bootstrapTable({
                height: tabHeight - 50,
                data: JsonData != "" ? JSON.parse(JsonData) : "",
                dataType: "json",
                columns: [
                    { align: 'center', width: "30px", checkbox: true },
                    { align: 'center', width: "30px", formatter: function (value, row, index) { return index + 1 }, sortable: true },
                    //{ field: 'DH', align: 'center', width: "120px", sortable: true },//档号改序号
                    { field: 'Term', align: 'center', width: "50px", sortable: true },
                    { field: 'Blamer', align: 'center', width: "50px", sortable: true },
                    //{ field: 'ItemNo', align: 'center', width: "80px", sortable: true },
                    { field: 'DPH', align: 'center', width: "80px" },
                    { field: 'SYer', align: 'center', width: "80px", sortable: true },
                    //{ field: 'MainPerson', align: 'center', width: "100px" },//主要人物
                    //{ field: 'ShootPlace', align: 'center', width: "100px" },//拍摄地点
                    { field: 'Title', align: 'left', width: "0" },
                    { field: 'SYDate', align: 'center', width: "80px", sortable: true },
                    { align: 'center', width: "80px", formatter: operateFormatter3, sortable: true },
                    { field: 'Remark', align: 'center', width: "80px" },
                ],
                //toolbar: '#toolbar',//工具按钮用哪个容器
                buttonsClass: "sm btn-white",//按钮class
                //pageSize: 100,//分页条数
                clickToSelect: true,//设置true 将在点击行时，自动选择单选或复选框
                singleSelect: true,//为true则禁止多选
                cache: false,//是否缓存
                cookie: true,//是否启用cookie
                cookieIdTable: "TImageSon",//cookie键值
                pagination: false,//是否分页
                showColumns: false,//是否显示所有的列
                showRefresh: false,//是否显示刷新按钮
                search: false,//是否启用搜索
                showPaginationSwitch: false,//是否显示分页切换按钮
                showExport: false,//是否启用导出
                striped: false,//是否显示行间隔色
                detailView: false,//是否显示切换视图列
                onDblClickRow: function (row, obj) { //双击行事件
                    //showPage('修改照片档案信息', '/scan3/ImageSonEdit.aspx?ID=' + row.ID, 800, 550, true);
                    location.href = "ImageSon.aspx?ParentID=" + (row.ID) + "&DH=" + (row.DH);
                }
            });
        }

        function operateFormatter3(value, row, index) {
            if (row.OpenState == "Y") {
                return ["<span title=\"开放\" class=\"text-success\" >开放</sapn>"];
            }
            else if (row.OpenState == "N") {
                return ["<span title=\"不开放\" class=\"text-danger\" >不开放</sapn>"];
            } else {
                return ["<span>-</sapn>"];
            }
        }
    </script>
}
